<?php

function chap0_sf_post()
{
	if ( !User::is_login() )
	{
		Dao::flash('error', "登录后才能发言");
		redirect(url(ROUTE_HTML_APP, url_sfparams('chap0','login')), 0);
	}

	if ( empty($_POST['post']) )
	{
		Dao::flash('error', "发言内容不能为空");
		redirect(url(ROUTE_HTML_APP, url_params('chap0','index')), 0);
	}

	$user = User::current_user();
	$post = array(
			'user_id'	=> G::val($user, 'id'),
			'user_name'	=> G::val($user, 'name'),
			'post'	=> G::val($_POST, 'post'),
		);
	$ret = Post::save($post);
	if ( !$ret['status'] )
	{
		Dao::flash('error', $ret['msg']);
		redirect(url(ROUTE_HTML_APP, url_sfparams('chap0','index')), 0);
	}

	Dao::flash('success', '发送成功');
	redirect(url(ROUTE_HTML_APP, url_params('chap0','index')), 0);
}

?>